package com.xilai.cuteBoy.common.plugin;

import org.mybatis.generator.api.IntrospectedColumn;
import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.dom.java.CompilationUnit;
import org.mybatis.generator.api.dom.java.Field;
import org.mybatis.generator.api.dom.java.InnerClass;
import org.mybatis.generator.api.dom.java.TopLevelClass;
import org.mybatis.generator.internal.DefaultCommentGenerator;

import java.text.SimpleDateFormat;

/*************************************************************
 * Description: 生成model中,字段增加注释
 * Author: Ren Binghong
 * CreateTime: 2017/5/2
 * Copyright © 西安喜来快递有限公司 All right reserved
 ************************************************************/
public class CommentGenerator extends DefaultCommentGenerator {


    @Override
    public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable) {
        super.addClassComment(innerClass, introspectedTable);
//        innerClass.addJavaDocLine("/*************************************************************");
//        innerClass.addJavaDocLine(" * Description: ");
//        innerClass.addJavaDocLine(" * Author: ");
//        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy/MM/dd");
//        innerClass.addJavaDocLine(" * CreateTime: "+simpleDateFormat.format(System.currentTimeMillis()));
//        innerClass.addJavaDocLine(" * Copyright © 西安喜来快递有限公司 All right reserved");
//        addJavadocTag(innerClass,false);
//        innerClass.addJavaDocLine(" ************************************************************/");

    }


    @Override
    public void addFieldComment(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
        super.addFieldComment(field, introspectedTable, introspectedColumn);
        if (introspectedColumn.getRemarks() != null && !introspectedColumn.getRemarks().equals("")) {
            field.addJavaDocLine("/**");
            field.addJavaDocLine(" * " + introspectedColumn.getRemarks());
            addJavadocTag(field, false);
            field.addJavaDocLine(" */");
        }
    }


}
